package com.hopu.blb_erp.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hopu.blb_erp.mapper.SiteMapper;
import com.hopu.blb_erp.entity.PageEntity;
import com.hopu.blb_erp.entity.Site;
import com.hopu.blb_erp.service.SiteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SiteServiceImpl extends ServiceImpl<SiteMapper, Site> implements SiteService {

    @Autowired
    private SiteMapper siteMapper;

    @Override
    public Integer findCount() {
        return siteMapper.selectCount();
    }

    @Override
    public PageEntity<Site> findPage(Integer current, Integer length) {
        Integer count = siteMapper.selectCount();
        List<Site> sites = siteMapper.selectPage((current - 1) * length, length);
        PageEntity<Site> sitePageEntity = new PageEntity<>();
        sitePageEntity.setData(sites);
        sitePageEntity.setCurrent(current);
        sitePageEntity.setCount(count);
        return sitePageEntity;
    }
}
